import request from '@/axios'
import type { CurdData } from './types'

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/category', params })
}

export const delListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: '/admin/category', data: { ids } })
}

export const getInfoApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/category/' + id })
}

export const saveDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/category/', data })
  } else {
    return request.post({ url: '/admin/category/', data })
  }
}

export const getCategoryListApi = (params: any) => {
  return request.get({ url: '/admin/category/select', params })
}

export const getFirstCategorySelect = (params?: any) => {
  return request.get({ url: '/admin/category/select' })
}

export const getCategorySelectTree = (params?: any) => {
  return request.get({ url: '/admin/category/selectTree' })
}
